﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BusinessLogic;
using Entities;

namespace ATM_System_Mock1_G2
{
    public partial class Transfer : System.Web.UI.Page
    {
        CardEntites card = new CardEntites();
        AccountEntites account_E = new AccountEntites();
        CustomerBL cusB = new CustomerBL();
        AccountBL account = new AccountBL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
                DataTable dt = new DataTable();
                card.CardNo = HttpContext.Current.Session["CardNo"].ToString();
                dt = cusB.Diplay(card);
                
                lb1.Text = dt.Rows[0]["Name"].ToString();
                lb_2.Text = dt.Rows[0]["AccountID"].ToString();
                
                
            }

            if (txt_ReceiveID.Text != "")
            {
                Session["AccountReceiveID"] = txt_ReceiveID.Text;
            }
            if (lb_2.Text != "")
            {
                Session["AccountTransferID"] = lb_2.Text;
            }
            txt_ReceiveID.Focus();
        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            

            Response.Redirect("Home.aspx");
        }
        public void CheckAccountID()
        {
            if (String.IsNullOrWhiteSpace(txt_ReceiveID.Text))
            {
                lb_thongbao.Text = "* AccountID is not null";
            }
            else
            { 
                account_E.AccountID = int.Parse(txt_ReceiveID.Text);
                if (account.CheckAccountID(account_E) == true)
                {
                    Response.Redirect("Transfer2.aspx");
                }
                else {
                    lb_thongbao.Text = "AccountID is not exist";
                }

            }
        }
        protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
        {
            CheckAccountID();
        }

        protected void btn_Num1_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 1;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 2;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 3;
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 4;
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 5;
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 6;
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 7;
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 8;
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 9;
        }

        protected void Button13_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text += 0;
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            txt_ReceiveID.Text ="";
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("Home.aspx");
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            CheckAccountID();
        }
    }
}